/*
=======================================================================

  BOTS General Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_GENERALCOMMANDSMENU_VOTE		1
#define BOTS_GENERALCOMMANDSMENU_KILL		2
#define BOTS_GENERALCOMMANDSMENU_TOGALARM	5
#define BOTS_GENERALCOMMANDSMENU_TOGSCOUT	9
#define BOTS_GENERALCOMMANDSMENU_MUTE		10
#define BOTS_GENERALCOMMANDSMENU_UNMUTE		11
#define BOTS_GENERALCOMMANDSMENU_GRENTOG	12
#define BOTS_GENERALCOMMANDSMENU_POWERUP	13

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	vote;
  menutext_s	kill;
  menutext_s	togalarm;
  menutext_s	togscout;
  menutext_s	mute;
  menutext_s	unmute;
  menutext_s	grentog;
  menutext_s	powerup;
  menutext_s	cancel;
} BOTSGeneralCommands_t;

static BOTSGeneralCommands_t	s_BOTSGeneralCommandsMenu;

/*
=================
BOTS_GeneralCommandsMenu_Event
callback routine
=================
*/
void BOTS_GeneralCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_GENERALCOMMANDSMENU_VOTE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "mapvote\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_KILL:
		trap_Cmd_ExecuteText( EXEC_APPEND, "kill\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_TOGALARM:
		trap_Cmd_ExecuteText( EXEC_APPEND, "togalarm\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_TOGSCOUT:
		trap_Cmd_ExecuteText( EXEC_APPEND, "togscout\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_MUTE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "mute\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_UNMUTE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "unmute\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_GRENTOG:
		trap_Cmd_ExecuteText( EXEC_APPEND, "grentog\n" );
		break;
	case BOTS_GENERALCOMMANDSMENU_POWERUP:
		trap_Cmd_ExecuteText( EXEC_APPEND, "powerup\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_GeneralCommandsMenu_Init
=================
*/
void BOTS_GeneralCommandsMenu_Init() 
{
	int		y;

	memset( &s_BOTSGeneralCommandsMenu, 0 ,sizeof(BOTSGeneralCommands_t) );
	s_BOTSGeneralCommandsMenu.menu.wrapAround = qtrue;
	s_BOTSGeneralCommandsMenu.menu.fullscreen = qfalse;

	y = 96;
	s_BOTSGeneralCommandsMenu.title.generic.type	= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_BOTSGeneralCommandsMenu.title.generic.x		= 320;
	s_BOTSGeneralCommandsMenu.title.generic.y		= y;
	s_BOTSGeneralCommandsMenu.title.string			= "General Commands Menu";
	s_BOTSGeneralCommandsMenu.title.color			= color_bots_menu;
	s_BOTSGeneralCommandsMenu.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.vote.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.vote.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.vote.generic.x		= 320;
	s_BOTSGeneralCommandsMenu.vote.generic.y		= y;
	s_BOTSGeneralCommandsMenu.vote.generic.id		= BOTS_GENERALCOMMANDSMENU_VOTE;
	s_BOTSGeneralCommandsMenu.vote.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.vote.string			= "VOTING MENU - vote";
	s_BOTSGeneralCommandsMenu.vote.color			= color_bots_menu;
	s_BOTSGeneralCommandsMenu.vote.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.kill.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.kill.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.kill.generic.x		= 320;
	s_BOTSGeneralCommandsMenu.kill.generic.y		= y;
	s_BOTSGeneralCommandsMenu.kill.generic.id		= BOTS_GENERALCOMMANDSMENU_KILL;
	s_BOTSGeneralCommandsMenu.kill.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.kill.string			= "KILL YOURSELF - kill";
	s_BOTSGeneralCommandsMenu.kill.color			= color_bots_menu;
	s_BOTSGeneralCommandsMenu.kill.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.togalarm.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.togalarm.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.togalarm.generic.x		= 320;
	s_BOTSGeneralCommandsMenu.togalarm.generic.y		= y;
	s_BOTSGeneralCommandsMenu.togalarm.generic.id		= BOTS_GENERALCOMMANDSMENU_TOGALARM;
	s_BOTSGeneralCommandsMenu.togalarm.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.togalarm.string			= "TOGGLE ALARM MESSAGES - togalarm";
	s_BOTSGeneralCommandsMenu.togalarm.color			= color_bots_menu;
	s_BOTSGeneralCommandsMenu.togalarm.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.togscout.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.togscout.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.togscout.generic.x		= 320;
	s_BOTSGeneralCommandsMenu.togscout.generic.y		= y;
	s_BOTSGeneralCommandsMenu.togscout.generic.id		= BOTS_GENERALCOMMANDSMENU_TOGSCOUT;
	s_BOTSGeneralCommandsMenu.togscout.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.togscout.string			= "TOGGLE CAPTAIN SCOUTING REPORTS - togscout";
	s_BOTSGeneralCommandsMenu.togscout.color			= color_bots_menu;
	s_BOTSGeneralCommandsMenu.togscout.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.mute.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.mute.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.mute.generic.x		= 320;
	s_BOTSGeneralCommandsMenu.mute.generic.y		= y;
	s_BOTSGeneralCommandsMenu.mute.generic.id		= BOTS_GENERALCOMMANDSMENU_MUTE;
	s_BOTSGeneralCommandsMenu.mute.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.mute.string			= "MUTE PLAYER - mute";
	s_BOTSGeneralCommandsMenu.mute.color			= color_bots_menu;
	s_BOTSGeneralCommandsMenu.mute.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.unmute.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.unmute.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.unmute.generic.x			= 320;
	s_BOTSGeneralCommandsMenu.unmute.generic.y			= y;
	s_BOTSGeneralCommandsMenu.unmute.generic.id			= BOTS_GENERALCOMMANDSMENU_UNMUTE;
	s_BOTSGeneralCommandsMenu.unmute.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.unmute.string				= "UNMUTE PLAYER - unmute";
	s_BOTSGeneralCommandsMenu.unmute.color				= color_bots_menu;
	s_BOTSGeneralCommandsMenu.unmute.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.grentog.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.grentog.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.grentog.generic.x			= 320;
	s_BOTSGeneralCommandsMenu.grentog.generic.y			= y;
	s_BOTSGeneralCommandsMenu.grentog.generic.id		= BOTS_GENERALCOMMANDSMENU_GRENTOG;
	s_BOTSGeneralCommandsMenu.grentog.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.grentog.string			= "Specialty Grenades - grentog";
	s_BOTSGeneralCommandsMenu.grentog.color				= color_bots_menu;
	s_BOTSGeneralCommandsMenu.grentog.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.powerup.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.powerup.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.powerup.generic.x			= 320;
	s_BOTSGeneralCommandsMenu.powerup.generic.y			= y;
	s_BOTSGeneralCommandsMenu.powerup.generic.id		= BOTS_GENERALCOMMANDSMENU_POWERUP;
	s_BOTSGeneralCommandsMenu.powerup.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.powerup.string			= "Activate Powerup - powerup";
	s_BOTSGeneralCommandsMenu.powerup.color				= color_bots_menu;
	s_BOTSGeneralCommandsMenu.powerup.style				= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_BOTSGeneralCommandsMenu.cancel.generic.type		= MTYPE_PTEXT;
	s_BOTSGeneralCommandsMenu.cancel.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_BOTSGeneralCommandsMenu.cancel.generic.x			= 320;
	s_BOTSGeneralCommandsMenu.cancel.generic.y			= y;
	s_BOTSGeneralCommandsMenu.cancel.generic.id			= BOTS_CANCEL;
	s_BOTSGeneralCommandsMenu.cancel.generic.callback	= BOTS_GeneralCommandsMenu_Event; 
	s_BOTSGeneralCommandsMenu.cancel.string				= "CANCEL";
	s_BOTSGeneralCommandsMenu.cancel.color				= color_bots_menu;
	s_BOTSGeneralCommandsMenu.cancel.style				= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.title );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.vote );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.kill );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.togalarm );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.togscout );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.mute );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.unmute );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.grentog );
	Menu_AddItem( &s_BOTSGeneralCommandsMenu.menu, &s_BOTSGeneralCommandsMenu.cancel );
}

void BOTS_GeneralCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_GeneralCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_BOTSGeneralCommandsMenu.menu );
}
